import {observable} from 'mobx'; 
import Taro from '@tarojs/taro';
import {http} from '../../util/common'
import * as cfApi from '../../api/cfApi'
// import { Icon } from '@tarojs/components';

const CfStore = observable({
  name: 'cf',
  changeName(){
    console.log('tag', this )
    CfStore.name='liuu'
  },
  // 获取首页数据
  fetchHomeData() {
    return http({
      url: cfApi.Home_Data,
      method: 'GET'
    }).then(res => {
      console.log('获取首页数据', res)
      if (res.code === '200' ){
        console.log(res.code === 200, res.data)
        return res.data
      } else {
        Taro.showToast({
          title: '请求错误',
          icon: 'none'
        })
      }
    })
  },
  // 获取车品牌
  fetchCarBrand() {
    return http({
      url: cfApi.CAR_BRAND,
      method: 'GET'
    }).then(res => {
      console.log('res', res)
      return res
    }).catch(err => 
      console.log('err', err)
    )}
})
export default CfStore